#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <math.h>
#include <unordered_set>

using namespace std;

// 1461. 检查一个字符串是否包含所有长度为 K 的二进制子串
// https://leetcode.cn/problems/check-if-a-string-contains-all-binary-codes-of-size-k/

class Solution
{
public:
    bool hasAllCodes(string s, int k)
    {
        int maxNum = 1 << k;
        unordered_set<string> seen;
        for (int i = 0; i <= s.size() - k; i++)
        {
            seen.insert(s.substr(i, k));
            if (seen.size() == maxNum)
                return true;
        }
        return false;
    }
};

int main()
{
    string s = "00110110";
    int k = 2;
    Solution solution{};
    solution.hasAllCodes(s, k);
    return 0;
}